<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>全所电子归档</title>
		<meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  <link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="../../layuiadmin/style/admin.css" media="all">
	</head>
	<style>
		.selectrecord{
			background-image: url(../../images/record/2019-11-01_154437.png);
			height: 33px;
			width: 568px;
			text-align: left;
		}
		/*下拉按钮样式**/
        .down-panel{
            padding: 0;
            z-index: 100;
            overflow:visible;
        }
        .down-panel .layui-select-title{
            padding-right:30px;
            padding-left:10px;
            overflow:visible;
        }
        .down-panel dl{
            color: #000;
            top: 30px;
            font-size: 14px;
        }
        .down-panel .layui-select-title i{
            border-top-color:#fff;
        }
        .down-panel:hover{
            opacity:1 !important;
            filter:alpha(opacity=100) !important;
            color:#fff
        }
        .layui-anim-upbit{
            top: 100% !important;
            z-index: 999999 !important;
        }
        .layui-anim-upbit dd {
            text-align: left;
        }
        .over-hover{
            overflow: visible; z-index: 9999;
        }
        .layui-select-title{
            background-color: #008FBF;
        }
        .layui-table-box{
            overflow: visible;!important;
        }
        .layui-table-body{
            overflow: visible;!important;
        }
	</style>
	<body>
<form method="post" id="form1" enctype="multipart/form-data">
	<div class="layui-fluid">
		<div class="layui-card">
			<div class="layui-form layui-card-header layuiadmin-card-header-auto">
				<!--我的电子文档-->
		    	<div class="layui-form-item">
		    		<div class="layui-inline">
		            	<!--客户名称查询条件-->
		            	<label class="layui-form-label"></label>
			            <div class="layui-input-inline">
			              <input type="text" name="client_name" id="clientname"  autocomplete="off" class="layui-input">
			            </div>
         			</div>
         			
         			<div class="layui-inline">
			            <div class="layui-input-inline">
			              <select id="stateclient" style="width: 100px;height: 37px;">
			                <option value="1">案号搜索</option>
							<option value="2">上传人搜索</option>
							<option value="3">归档文件搜索</option>
			              </select>
			            </div>
			        </div>
					<div class="layui-inline">
			            <div class="layui-input-inline">
			              <input type="button" id="selec" value="检索" data-type="reload" class="layui-btn layui-btn-normal">
			            </div>
         			</div>
       			</div> 
       		</div>
       		<div class="layui-card-body">
	         			<table id="recordall" lay-filter="test"></table>
	         			<div id="laypage"></div>
	         			<script type="text/html"  id="merchantBar">
				            <div class="layui-btn-group layui-form">
				                <button type="button" class="layui-btn layui-btn-xs layui-unselect layui-form-select down-panel">
				                    <div class="layui-select-title" onmouseover="downPanel(this)">
				                       		     操作
				                        <i class="layui-edge"></i>
				                    </div>
				                    <dl class="layui-anim layui-anim-upbit">
					                    <dd>
					                      	<i class="layui-icon"></i>
					                    	<a lay-event="down">下载</a>
					                    </dd>
					                    <dd>
					                        <i class="layui-icon"></i>
					                        <a lay-event="update">修改</a>
					                    </dd>
					                    <dd>
					                        <i class="layui-icon"></i>
					                        <a lay-event="del">删除</a>
					                    </dd>
				                    </dl>
				                    </button>
				                </div>
				
				        </script>
	        </div>
        
			
		</div>
	</div>
	<!--案件归档-->
</form>
<script src="../../layuiadmin/layui/layui.js"></script>
<script src="../../layuiadmin/jquery/jquery.min.js" type="text/javascript"></script>
<script src="../../layuiadmin/js/system/jquery.cookie.js"></script>
<script>
	    	function createrFormat(o){
                	return o;
   			}
			$(function(){
				var client = $("input[name='client_name']").val();
				var state = $("#stateclient").val();
				layui.use(['table','element','form'], function(){
					var table = layui.table,
					 element = layui.element,
					 form = layui.form; 
			        
			        table.render({
					    elem: '#recordall'
					    ,url: 'http://localhost:8080/record/listrecordall' //数据接口
					    ,cols: [[ //表头
					       {field: 'recordId', title: '档案号', fixed: 'left'}
					      ,{templet:'<div>{{createrFormat(d.caseId.caseId)}}<\/div>',title: '案件号', sort: true}
					      ,{field: 'archivefile', title: '归档文件'}
					      ,{templet:'<div>{{createrFormat(d.empId.empName)}}<\/div>', title: '上传人'}
					      ,{templet:'<div>{{createrFormat(d.turnovertime)}}<\/div>', title: '最后上传时间', sort: true}
					      ,{title: '操作', fixed: 'right', align:'center',toolbar: '#merchantBar'}
					    ]]
					    ,id:"records"
					    ,page: true
					    ,where:{
					    	stateclient:state,
					    	casetext:client
					    }
					  });
					var $ = layui.$, active = {
		                reload: function(){
		                	var state = $("#stateclient").val();
		  					var casetext1 = $("#client").val();
		                    //执行重载
		                    table.reload('records', {
		                        page: {
		                            curr: 1 //重新从第 1 页开始
		                        }
		                        ,where: {
		                            stateclient:state,
				    				casetext:client
		                        }
		                    });
	               		}
	           		 };
				  	 	$('#selec').on('click', function () {
				  	 		client = $("input[name='client_name']").val();
						    var type = $(this).data('type');
						    active[type] ? active[type].call(this) : '';
						})
				  	table.on('tool(test)', function(obj){ //注：tool 是工具条事件名，test 是 table 原始容器的属性 lay-filter="对应的值"
					  var data = obj.data; //获得当前行数据
					  var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
					  var tr = obj.tr; //获得当前行 tr 的 DOM 对象（如果有的话）
					 var caseId=data.recordId.caseId;
					 var archivefile=data.archivefile;
					 var empId=data.empId.empId;
					 var turnovertime=data.turnovertime;
					  if(layEvent === 'down'){ //下载
					    $.ajax({
					    	type:"post",
					    	url:"http://localhost:8080/record/queryurl",
					    	async:true,
					    	data:{"caseId":caseId,"archivefile":archivefile,"empId":empId,"turnovertime":turnovertime},
					    	success:function(obj){
								location.href="http://localhost:8080/record/downloados?fileurl="+obj;
					    	}
					    });
					    
					  } else if(layEvent === 'del'){ //删除
					    layer.confirm('真的删除行么', function(index){
					      obj.del(); //删除对应行（tr）的DOM结构，并更新缓存
					      layer.close(index);
					      $.post('http://localhost:8080/record/deleteos',
					      	{"caseId":caseId,"archivefile":archivefile,"empId":empId,"turnovertime":turnovertime},
					      	function(datebase){
					      	if(datebase=="ok"){
					      		alert("删除成功!");
					      		location.reload();	
					      	}else{
					      		alert("删除失败!");
					      	}
					      });
					    });
					  } else if(layEvent === 'update'){ //编辑
					  	parentData = data;
					    layer.open({
					    	type: 2,
                                title: '归档案件修改',
                                maxmin: true,
                                offset: '10px',
                                skin: 'layui-layer-lan',
                                shadeClose: true, //点击遮罩关闭层
                                area : ['1000px' , '800px'],
                                content: 'record_update.html',
					    });
					  }
					}); 	
				});
			});
			function selectCase(){
				layui.use('layer', function(){
				  var layer = layui.layer;
				  layer.open({
                        type: 2,
                        anim: 4,
                        shadeClose:true,
                        title: ['案件选择', 'font-size:18px;'],
                        offset: '10px',
                        area: ['920px', '700px'],
                        content:'record_caseselect.html'
                 });
				});  
				
			}
			function tijiaowenjian(){
			  	 	var userid =  $.cookie("redisId");
			  	 	$("#mpid").val(userid);
			  	 	$("#aseName").val($("#casechoice").val())
			  	 	var formdata=new FormData(document.getElementById("form1"));
					  $.ajax({
			            url:"http://localhost:8080/record/transmitted",
			            type:"post",
			            data:formdata,
			            processData:false,
			            contentType:false,
			            success:function(data){
			                console.log("over..");
			                if(data=="ok"){
			                    alert("发送成功")
			                    location.reload();
			                }else{
			                    alert("失败!")
			                }
			            },
			            error:function(e){
			                alert("上传文件超出范围，请选择小于1mb的文件！");
			            }
       				 });
				}
			function downPanel(that) {
		        var nodes = layui.jquery(".layui-form-selected");
		        var hoverNodes = layui.jquery(".over-hover");
		        var current = layui.jquery(that).parent();
		        if (current.hasClass("layui-form-selected")) {
		            nodes.removeClass("layui-form-selected");
		            hoverNodes.removeClass("over-hover");
		        } else {
		            if (nodes.length > 0) {
		                nodes.removeClass("layui-form-selected");
		                hoverNodes.removeClass("over-hover");
		            }
		            current.addClass("layui-form-selected");
		            current.parent(".layui-form").parent().addClass("over-hover");
		        }
		
		        layui.jquery(document).click(function(event){
		            var _con2 = layui.jquery(".down-panel");
		            if(!_con2.is(event.target) && (_con2.has(event.target).length ===0)){
		                _con2.removeClass("layui-form-selected");
		                hoverNodes.removeClass("over-hover");
		                nodes.removeClass("layui-form-selected");
		            }
		        });
		    }
	   	</script>
	</body>
</html>
